package com.cainli.szbus.data.requestmanager;

import com.cainli.szbus.data.operation.BusLineListOperation;
import com.cainli.szbus.data.operation.BusStatListOperation;
import com.foxykeep.datadroid.requestmanager.Request;

/**
 * Class used to create the {@link Request}s.
 * 
 * @author cainli
 *
 */
public final class RequestFactory {

    // Request types
    public static final int REQUEST_TYPE_BUSLINE_LIST = 0;
    public static final int REQUEST_TYPE_BUSSTATS_LIST = 1;

    // Response data
    public static final String BUNDLE_EXTRA_BUSLINE_LIST =
            "com.cainli.szbus.busLineList";
    public static final String BUNDLE_EXTRA_BUSSTATS_LIST =
    		"com.cainli.szbus.busLineStats";

    private RequestFactory() {
        // no public constructor
    }

    /**
     * Create the request to get the list of persons 
     *<pre> TODO save it in the database.</pre>
     *
     * @param returnFormat 0 for XML, 1 for JSON.
     * @return The request.
     */
    public static Request getBusLineListRequest(int returnFormat,String city,String keyword,int with_xys) {
        Request request = new Request(REQUEST_TYPE_BUSLINE_LIST);
        request.put(BusLineListOperation.PARAM_RETURN_FORMAT, returnFormat);
        request.put(BusLineListOperation.PARAM_CITY, city);
        request.put(BusLineListOperation.PARAM__KEYWORD, keyword);
        request.put(BusLineListOperation.PARAM_WITH_XYS, with_xys);
        request.setMemoryCacheEnabled(true);
        return request;
    }
    public static Request getBusLineListRequest(String city,String keyword,int with_xys) {
    	return RequestFactory.getBusLineListRequest(1,city, keyword, with_xys);
    }
    
    public static Request getBusStatListRequest(String city,String keyword) {
    	Request request = new Request(REQUEST_TYPE_BUSSTATS_LIST);
        request.put(BusStatListOperation.PARAM_RETURN_FORMAT, 1);
        request.put(BusStatListOperation.PARAM_CITY, city);
        request.put(BusStatListOperation.PARAM_KEYWORD, keyword);
        request.setMemoryCacheEnabled(true);
        return request;
    }

}
